10. 最小值/最大值重缩放器编码练习
最小值/最大值重缩放器编码练习
Question:
Start Quiz:
""" quiz materials for feature scaling clustering """
### FYI, the most straightforward implementation might
### throw a divide-by-zero error, if the min and max
### values are the same
### but think about this for a second--that means that every
### data point has the same value for that feature!
### why would you rescale it? Or even use it at all?
def featureScaling(arr):
return None
# tests of your feature scaler--line below is input data
data = [115, 140, 175]
print featureScaling(data)
Solution:
INSTRUCTOR NOTE:
要思考的问题:如果 x_max 和 x_min 相同怎么办?例如,假设输入特征的列表是 [10, 10, 10]——分母将为零。我们的建议是通常为每个新特征指定 0.5(0.0 和 1.0 中间),但这实际上由你自己决定。要点是,这个公式可能会有问题。
特征缩放过程应返回数据列表中所有三个值的重缩放值的列表。